<template>
	<iframe style="width:100%;height:80vh" frameborder="false" :src="fullUrl"></iframe>
</template>

<script>
import {
    ZABBIX_HOST,
		ZABBIX_API,
		ZABBIX_USER,
		ZABBIX_PWD
} from '@/config'
export default {
	props:{
		url:{
      type: String,
      default: function() {
        return '';
      }
    }
	},
  data() {
		var zabbixHost = ZABBIX_HOST;
		var loginUrl = ZABBIX_API+"/api_jsonrpc.php";
		var loginParam = {
				"jsonrpc": "2.0",
				"method": "user.login",
				"params": {
						"user": ZABBIX_USER,
						"password": ZABBIX_PWD
				},
				"id": 1
		};
		var sid = "";
    $.ajax({
			url: loginUrl,
			data: JSON.stringify(loginParam),
			cache: false,
			async: false,
			type: "POST",
			contentType: "application/json",
			dataType: 'json',
			ajaxStart: function() {
					NProgress.start();
			},
			ajaxStop: function() {
					NProgress.done();
			},
			success: function(data) {
				sid = data.result;
			}
    });
    return {
			fullUrl:ZABBIX_API+"/index.php?"+sid+","+this.url,
      sessionId: sid
    }
  }
}
</script>
